﻿using System;
using System.Collections.Generic;

/*
 * Write a program that reads a string from the console and prints all
 * different letters in the string along with information how many times each letter is found. 
 */

namespace DifferentLetters
{
    class DifferentLetters
    {
        static void PrintCharacters(Dictionary<char, int> characters)
        {
            foreach (var character in characters)
            {
                Console.WriteLine("{0} : {1}", character.Key, character.Value);
            }
        }

        static Dictionary<char, int> LettersCount(string text)
        {
            Dictionary<char, int> characters = new Dictionary<char, int>();

            foreach (char character in text)
            {
                if (!char.IsLetter(character)) //If is not letter => skip character
                {
                    continue;
                }

                if (characters.ContainsKey(character)) //if the character exist
                {
                    characters[character]++;
                    continue;
                }
                characters[character] = 1;
            }

            return characters;
        }

        static void Main()
        {
            Console.WriteLine("Enter a string:");

            var result = LettersCount(Console.ReadLine());

            PrintCharacters(result);
        }
    }
}
